package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.dao.EmployeeMapper;
import com.itheima.pojo.Employee;
import com.itheima.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    @Autowired
    private EmployeeMapper mapper;

    @Override
    public boolean login(String username, String password) {
        //接收,检查参数
        String username1 = null;
        String password1 = null;
        if (username != null || username != "" && password != null || password != "") {
            username1 = username;
            password1 = password;
        }
        //mapper根据得到的用户名,密码查询出对象数据
        Employee employee = mapper.selectByUserpass(username1, password1);
        //判断对象是否为null,
        System.out.println(employee);
        if (employee != null) {
            //判断是否禁用
            if (employee.getStatus() == 0) {
                throw new RuntimeException("账户禁用");
            }
        }
        return employee != null;
    }
}
